home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1985 August / Ahoy_Magazine_85-08_1985_Double_L.d64 / birthday sim (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  1KB  |  41 lines

  1. 0 rem << rr20-3 >>
  2. 1 print"[147]":poke53280,0:poke53281,6:poke646,1
  3. 2 rem  -- birthday simulator --
  4. 3 rem      rupert report #20
  5. 4 rem
  6. 10 rem - simulate groups of people with
  7. 11 rem   randomly chosen birthdays.
  8. 12 rem   each group contains 'nump'
  9. 13 rem   people.  bday(x) is the
  10. 14 rem   birthday (1-366) of the xth
  11. 15 rem   person.  ct(x) is the count of
  12. 16 rem   how many people in the group
  13. 17 rem   have day x as their birthday.
  14. 18 rem   success=1 if two people in
  15. 19 rem   one group have the same
  16. 20 rem   birthday.
  17. 21 rem
  18. 30 nump=24  :rem << change this
  19. 40 dim bday(nump),ct(366)
  20. 50 group=1
  21. 60 success=0
  22. 65 rem - reset count of used birthdays
  23. 70 for persn=1 to nump
  24. 80 ct(bday(persn))=0 : next
  25. 85 rem - choose each person's birthday
  26. 90 for persn=1 to nump
  27. 100 day=int(366*rnd(0))+1
  28. 110 bday(persn)=day
  29. 120 ct(day)=ct(day)+1
  30. 130 next persn
  31. 135 rem - check for duplicates
  32. 140 for persn=1 to nump
  33. 150 if ct(bday(persn))<2 then 180
  34. 160 success=1
  35. 170 persn=nump
  36. 180 next persn
  37. 190 if success=1 then ttl=ttl+1
  38. 200 print group"groups    ";
  39. 210 print ttl*100/group"% success"
  40. 220 group=group+1 : goto 60
  41.